//
//  baseTabBarViewController.m
//  testassembly
//
//  Created by liangang on 2018/3/8.
//  Copyright © 2018年 liangang. All rights reserved.
//

#import "baseTabBarViewController.h"
#import "ViewController.h"

@interface baseTabBarViewController ()

@end

@implementation baseTabBarViewController


- (void)viewDidLoad {
    [super viewDidLoad];
//    [self configChildVC];
    // Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self configChildVC];
}
-(void)configChildVC
{
    NSMutableArray *viewControllerArray = [[NSMutableArray alloc ]init];
    NSMutableArray *ItemsAttributes = [[NSMutableArray alloc]init ];
    [self.tabBarSourceModel.items enumerateObjectsUsingBlock:^(tabBarItemModel *obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
//        UINavigationController *nav = [[UINavigationController    alloc]initWithRootViewController:obj.vc.vc];
//        [viewControllerArray addObject:nav];
        SDWebImageManager *manager = [SDWebImageManager sharedManager];
        [manager loadImageWithURL:[NSURL URLWithString:obj.image] options:SDWebImageProgressiveDownload    progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
            
        } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
            
        }];
       
        UIImage *normalImage = [UIImage imageResize:[UIImage imageNamed:obj.image] andResizeTo:CGSizeMake(24, 19)];
        UIImage *slectImage = [UIImage imageResize:[UIImage imageNamed:obj.selectImage] andResizeTo:CGSizeMake(24, 19)];
        
        NSDictionary *dict = @{
                               CYLTabBarItemTitle : obj.name,
                               CYLTabBarItemImage : normalImage,
                               CYLTabBarItemSelectedImage : slectImage,
                               };
        [ItemsAttributes addObject:dict ];
    }];

    self.tabBarItemsAttributes = ItemsAttributes;
//    self.viewControllers  = viewControllerArray;
    ViewController   *vc1 = [[ViewController   alloc]init];
   
    vc1.url= WEBURL1;
     vc1.isHome   = YES;
    UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:vc1];
     ViewController   *vc2 = [[ViewController   alloc]init];
      vc2.url= WEBURL2;
    UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:vc2];
     ViewController   *vc3 = [[ViewController   alloc]init];
      vc3.url= WEBURL3;
    UINavigationController *nav3 = [[UINavigationController alloc]initWithRootViewController:vc3];
     ViewController   *vc4 = [[ViewController   alloc]init];
      vc4.url= WEBURL4;
    UINavigationController *nav4 = [[UINavigationController   alloc]initWithRootViewController:vc4];
    self.viewControllers =@[nav3,nav1,nav2,nav4];
   


}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
